const express = require('express');
const router = express.Router();

router.get('/forCurrentUser', (req, res) => {
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `2020${i}`,
            pICode: `pICode2020${i}`,
            batchNumber: `batchNumber${i}`,
            dealerCode: `dealerCode${i}`,
            cargoDescription: `cargoDescription${i}`,
            supplierCode: `supplierCode${i}`,
            country: 'country',
            marketDepartmentName: 'marketDepartmentName1',
            brandCode: `brandCode${i}`,
            deliveryTerms: 1,
            salesOrderPriceTerms: 1,
            paymentType: 1,
            totalAmount: 20205012,
            productAmount: 213123,
            currency: 1,
            createTime: '2020-02-17T06:05:12.351Z',
            confirmTime: '2020-02-17T06:05:12.351Z',
            status: 2,
            rowVersion: 'string',
            options: ['update', 'abandon', 'confirm', 'cancel', 'exportExcel', 'exportPdf']
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});

router.get('/details', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                title: 'title20191',
                cargoDescription: 'cargoDescription20191',
                model: 'model65465',
                supplierId: 'supplierId001',
                currency: 1,
                tradeMethodId: 'tradeMethodId56465',
                salesOrderPriceTerms: 3,
                paymentType: 1,
                deliveryTerms: 1,
                shippingPortId: '546',
                destinationPort: 'destinationPort',
                bankId: '20200',
            }
        }
    );
});

router.get('/:id', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                id: '20191',
                code: '20191',
                brandId: '65465',
                brandCode: 'brandCode',
                brandName: 'brandName',
                dealerId: '56465',
                dealerCode: 'dealerCode',
                batchNumber: 'batchNumber',
                pICode: 'pICode',
                productionMonth: 12,
                title: 'title',
                cargoDescription: 'cargoDescription',
                model: 'model',
                supplierId: '202000',
                supplierCode: 'supplierCode',
                supplierName: 'supplierName',
                currency: 1,
                tradeMethodId: '456',
                tradeMethodName: 'tradeMethodName',
                salesOrderPriceTerms: 3,
                paymentType: 1,
                productAmount: 2131,
                typeAmount: 2131231,
                deliveryTerms: 1,
                shippingPortId: '546',
                shippingPortName: 'shippingPortName',
                destinationPort: 'destinationPort',
                bankId: '12312',
                bankAccount: 'bankAccount',
                bankName: 'bankName',
                bankNameEng: 'bankNameEng',
                sWIFT: 'sWIFT',
                country: '中国',
                address: 'address',
                phoneNumber: 'phoneNumber',
                zipCode: 'zipCode',
                cNPJ: 'cNPJ',
                marketDepartmentId: 'marketDepartmentId',
                marketDepartmentName: 'marketDepartmentName',
                createTime: '2020-02-17T08:24:39.398Z',
                creatorName: 'creatorName',
                remark: 'remark',
                attachments: [
                    {
                        fileId: '001',
                        fileName: 'fileName001'
                    }
                ],
                rowVersion: 'string',
                options: ['update', 'abandon', 'confirm', 'cancel', 'exportExcel', 'exportPdf'],
                subPIPlacements: [{
                    id: '001',
                    placement: 'placement',
                    quantity: 123,
                    price: 21312.12,
                    amount: 2131,
                    remark: 'remark',
                }],
                subPIDetails: [{
                    id: '001',
                    order: '1',
                    partCode: 'partCode001',
                    partNameInChinese: 'partName001',
                    partNameInEnglish: 'partNameInEnglish',
                    quantity: 12,
                    price: 12.12,
                    amount: 123.23,
                    delayQTY: 21321.12,
                    delayAmount: 123,
                    remark: 'remark',
                }]
            }
        }
    );
});

router.put('/:id', (req, res) => {
    res.json(
        {
            message: '修改成功'
        }
    );
});

router.put('/:id/confirm', (req, res) => {
    res.json({
        message: '确认成功'
    });
});

router.put('/:id/confirmPi', (req, res) => {
    res.json({
        message: '发票确认成功'
    });
});

router.post('/', (req, res) => {
    res.json(
        {
            message: '提交成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.put('/:id/cancel', (req, res) => {
    res.json({
        message: '取消成功'
    });
});

module.exports = router;
